package com.example.test02.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.test02.R;

import java.util.List;
public class RelativeAdapter extends BaseAdapter {
    private Context context;
    private String[] types;
    private String[] names;
    private String[] phones;

    public RelativeAdapter(Context context, String[]types , String[] names, String[] phones) {
        this.context = context;
        this.types = types;
        this.names = names;
        this.phones = phones;
    }

    @Override
    public int getCount() {
        return types.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.relatives, parent, false);
        }

        ImageView icon = convertView.findViewById(R.id.relativeListView_ic);
        TextView type= convertView.findViewById(R.id.type);
        TextView name = convertView.findViewById(R.id.name);
        TextView phone = convertView.findViewById(R.id.phone);

        icon.setImageResource(R.drawable.no_gender_user);
        type.setText(types[position]);
        name.setText(names[position]);
        phone.setText(phones[position]);

        return convertView;
    }
}
